<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <body>

        <ui:composition template="./WEB-INF/templates/template.xhtml">

            <ui:define name="content">

                <div class="grid_16">
                    
                    <div class="grid_6">
                        
                        <h2>Información del Sprint</h2>
                        <div class="box">

                            <h:panelGrid styleClass="table" style="width: auto" columns="2">

                                <h:outputText value="Sprint Number: " styleClass="bold"/>
                                <h:outputText value="#{selectedSprintBean.sprintNumber}"/>
                                <h:outputText value="Initial Date: " styleClass="bold"/>
                                <h:outputText value="#{selectedSprintBean.initialDate}">
                                    <f:convertDateTime type="date" dateStyle="medium"/> 
                                </h:outputText>
                                <h:outputText value="End Date: " styleClass="bold"/>
                                <h:outputText value="#{selectedSprintBean.endDate}"> 
                                    <f:convertDateTime type="date" dateStyle="medium"/> 
                                </h:outputText>

                            </h:panelGrid>

                        </div>
                        
                    </div>
                    <div class="grid_10">
                        
                        <h2>Modificar tarea</h2>
                        <div class="box">
                            <div class="form-item">
                                
                                <h:form id="modifyForm" styleClass="prime-component">

                                    <h:panelGrid columns="2" styleClass="table" style="width: auto">

                                        <h:outputLabel for="selectTask" value="Selecciona una tarea:"/>
                                        <p:selectOneMenu id="selectTask" value="#{dashboardBean.task}" converter="#{taskConverter}" style="width: 220px" disabled="#{dashboardBean.doingTaskList.size() == 0}">
                                            <f:selectItems value="#{dashboardBean.doingTaskList}" var="task" itemLabel="#{task.description}" itemValue="#{task}"/>
                                        </p:selectOneMenu>

                                        <h:outputLabel for="modifyTime" value="Modifica su tiempo:"/>
                                        <h:inputText id="modifyTime" value="#{dashboardBean.time}" disabled="#{dashboardBean.doingTaskList.size() == 0}"/>

                                    </h:panelGrid>
                                    
                                    <h:panelGrid style="text-align: right" styleClass="table">
                                        <p:commandButton styleClass="button" value="Modificar" actionListener="#{dashboardBean.modify()}" disabled="#{dashboardBean.doingTaskList.size() == 0}" update="modifyForm :dashboard"/>
                                    </h:panelGrid>

                                </h:form>
                                
                            </div>
                        </div>
                        
                    </div>
                    
                    <div class="clear"></div>
                    <div class="separator_20"></div>
                    
                    <div class="dark-box">
                        <div class="header-todo">
                            <h2>TO DO</h2>
                        </div>
                        <div class="header-doing">
                            <h2>DOING</h2>
                        </div>
                        <div class="header-done">
                            <h2>DONE</h2>
                        </div>
                        <div class="clear"></div>
                    </div>
                    <div class="separator_10"></div>
                        
                    <h:form id="dashboard">
                        <p:dashboard model="#{dashboardBean.model}" >
                            <p:ajax event="reorder" listener="#{dashboardBean.handleReorder}" update=":modifyForm dashboard"/>
                            
                            <c:forEach items="#{dashboardBean.todoTaskList}" var="todoTask">
                                
                                <p:panel id="t_#{todoTask.idTask}" header="#{todoTask.description}" style="margin: 20px;">
                                    <div class="form-item">
                                        <h:panelGrid columns="2">
                                            <h:outputLabel value="Usuario:"/>
                                            <h:outputText value="#{todoTask.user.name}" style="margin-left: 10px;"/>
                                            <h:outputLabel value="Tiempo:"/>
                                            <h:outputText value="#{todoTask.time}" style="margin-left: 10px;"/>
                                        </h:panelGrid>
                                    </div>
                                </p:panel>
                            
                            </c:forEach>
                            
                            <c:forEach items="#{dashboardBean.doingTaskList}" var="doingTask">
                                
                                <p:panel id="t_#{doingTask.idTask}" header="#{doingTask.description}" style="margin: 20px;">
                                    <div class="form-item">
                                        <h:panelGrid columns="2">
                                            <h:outputLabel value="Usuario:"/>
                                            <h:outputText value="#{doingTask.user.name}" style="margin-left: 10px;"/>
                                            <h:outputLabel value="Tiempo:"/>
                                            <h:outputText value="#{doingTask.time}" style="margin-left: 10px;"/>
                                        </h:panelGrid>
                                    </div>
                                </p:panel>
                            
                            </c:forEach>
                            
                            <c:forEach items="#{dashboardBean.doneTaskList}" var="doneTask">
                                
                                <p:panel id="t_#{doneTask.idTask}" header="#{doneTask.description}" style="margin: 20px;">
                                    <div class="form-item">
                                        <h:panelGrid columns="2">
                                            <h:outputLabel value="Usuario:"/>
                                            <h:outputText value="#{doneTask.user.name}" style="margin-left: 10px;"/>
                                            <h:outputLabel value="Tiempo:"/>
                                            <h:outputText value="#{doneTask.time}" style="margin-left: 10px;"/>
                                        </h:panelGrid>
                                    </div>
                                </p:panel>
                            
                            </c:forEach>
                            
                        </p:dashboard>
                    </h:form>
                    
                    <div class="clear"></div>
                    
                </div>

                <div class="clear"></div>
            </ui:define>

        </ui:composition>

    </body>
</html>
